package com.bbva.kyfb.kyfbjpatlsb.dominiotlsb;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Embeddable;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.roo.addon.entity.RooIdentifier;

import flexjson.JSONDeserializer;
import flexjson.JSONSerializer;

/**
 * The Class TtlnemfdPK.
 */
@Configurable
@Embeddable
@RooIdentifier(dbManaged = true)
public final class TtlnemfdPK implements java.io.Serializable, org.springframework.beans.factory.aspectj.ConfigurableObject {

	/** The cod codprod. */
	@Column(name = "COD_CODPROD", nullable = false,columnDefinition = "INTEGER")
    private Integer codCodprod;

	/** The cod idioma. */
	@Column(name = "COD_IDIOMA", nullable = false,columnDefinition = "SMALLINT")
    private Short codIdioma;

	/**
	 * Instantiates a new ttlnemfd pk.
	 *
	 * @param codCodprod the cod codprod
	 * @param codIdioma the cod idioma
	 */
	public TtlnemfdPK(Integer codCodprod, Short codIdioma) {
        super();
        this.codCodprod = codCodprod;
        this.codIdioma = codIdioma;
    }

	/**
	 * Instantiates a new ttlnemfd pk.
	 */
	@SuppressWarnings("unused")
	private TtlnemfdPK() {
        super();
    }

	/**
	 * Gets the cod codprod.
	 *
	 * @return the cod codprod
	 */
	public Integer getCodCodprod() {
        return this.codCodprod;
    }

	/**
	 * Gets the cod idioma.
	 *
	 * @return the cod idioma
	 */
	public Short getCodIdioma() {
        return this.codIdioma;
    }

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null) return false;
        if (!(obj instanceof TtlnemfdPK)) return false;
        TtlnemfdPK other = (TtlnemfdPK) obj;
        if (codCodprod == null) {
            if (other.codCodprod != null) return false;
        } else if (!codCodprod.equals(other.codCodprod)) return false;
        if (codIdioma == null) {
            if (other.codIdioma != null) return false;
        } else if (!codIdioma.equals(other.codIdioma)) return false;
        return true;
    }

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
        final int prime = 31;
        int result = 17;
        result = prime * result + (codCodprod == null ? 0 : codCodprod.hashCode());
        result = prime * result + (codIdioma == null ? 0 : codIdioma.hashCode());
        return result;
    }

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 1L;

	/**
	 * To json.
	 *
	 * @return the string
	 */
	public String toJson() {
        return new JSONSerializer().exclude("*.class").serialize(this);
    }

	/**
	 * From json to ttlnemfd pk.
	 *
	 * @param json the json
	 * @return the ttlnemfd pk
	 */
	public static TtlnemfdPK fromJsonToTtlnemfdPK(String json) {
        return new JSONDeserializer<TtlnemfdPK>().use(null, TtlnemfdPK.class).deserialize(json);
    }

	/**
	 * To json array.
	 *
	 * @param collection the collection
	 * @return the string
	 */
	public static String toJsonArray(Collection<TtlnemfdPK> collection) {
        return new JSONSerializer().exclude("*.class").serialize(collection);
    }

	/**
	 * From json array to ttlnemfd p ks.
	 *
	 * @param json the json
	 * @return the collection
	 */
	public static Collection<TtlnemfdPK> fromJsonArrayToTtlnemfdPKs(String json) {
        return new JSONDeserializer<List<TtlnemfdPK>>().use(null, ArrayList.class).use("values", TtlnemfdPK.class).deserialize(json);
    }
}
